/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.openams.server.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mike
 */
@Entity
@Table(name = "assetcategories", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"AssetCategoryID"}),
    @UniqueConstraint(columnNames = {"AssetCategoryName"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AssetCategory.findAll", query = "SELECT a FROM AssetCategory a"),
    @NamedQuery(name = "AssetCategory.findByAssetCategoryID", query = "SELECT a FROM AssetCategory a WHERE a.assetCategoryID = :assetCategoryID"),
    @NamedQuery(name = "AssetCategory.findByAssetCategoryName", query = "SELECT a FROM AssetCategory a WHERE a.assetCategoryName = :assetCategoryName"),
    @NamedQuery(name = "AssetCategory.findByAssetCategoryDescription", query = "SELECT a FROM AssetCategory a WHERE a.assetCategoryDescription = :assetCategoryDescription"),
    @NamedQuery(name = "AssetCategory.findByAssetCategoryType", query = "SELECT a FROM AssetCategory a WHERE a.assetCategoryType = :assetCategoryType")})
public class AssetCategory implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "AssetCategoryID", nullable = false)
    private Integer assetCategoryID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 64)
    @Column(name = "AssetCategoryName", nullable = false, length = 64)
    private String assetCategoryName;
    @Size(max = 1024)
    @Column(name = "AssetCategoryDescription", length = 1024)
    private String assetCategoryDescription;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 8)
    @Column(name = "AssetCategoryType", nullable = false, length = 8)
    private String assetCategoryType;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "assetCategoryID", fetch = FetchType.LAZY)
    private Collection<LinearAsset> linearAssetCollection;
    @JoinColumn(name = "AttributeDatasetTemplateHierarchyID", referencedColumnName = "DatasetTemplateHierarchyID", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private DatasetTemplateHierarchy attributeDatasetTemplateHierarchyID;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "assetCategoryID", fetch = FetchType.LAZY)
    private Collection<DiscreteAsset> discreteAssetCollection;

    public AssetCategory() {
    }

    public AssetCategory(Integer assetCategoryID) {
        this.assetCategoryID = assetCategoryID;
    }

    public AssetCategory(Integer assetCategoryID, String assetCategoryName, String assetCategoryType) {
        this.assetCategoryID = assetCategoryID;
        this.assetCategoryName = assetCategoryName;
        this.assetCategoryType = assetCategoryType;
    }

    public Integer getAssetCategoryID() {
        return assetCategoryID;
    }

    public void setAssetCategoryID(Integer assetCategoryID) {
        this.assetCategoryID = assetCategoryID;
    }

    public String getAssetCategoryName() {
        return assetCategoryName;
    }

    public void setAssetCategoryName(String assetCategoryName) {
        this.assetCategoryName = assetCategoryName;
    }

    public String getAssetCategoryDescription() {
        return assetCategoryDescription;
    }

    public void setAssetCategoryDescription(String assetCategoryDescription) {
        this.assetCategoryDescription = assetCategoryDescription;
    }

    public String getAssetCategoryType() {
        return assetCategoryType;
    }

    public void setAssetCategoryType(String assetCategoryType) {
        this.assetCategoryType = assetCategoryType;
    }

    @XmlTransient
    public Collection<LinearAsset> getLinearAssetCollection() {
        return linearAssetCollection;
    }

    public void setLinearAssetCollection(Collection<LinearAsset> linearAssetCollection) {
        this.linearAssetCollection = linearAssetCollection;
    }

    public DatasetTemplateHierarchy getAttributeDatasetTemplateHierarchyID() {
        return attributeDatasetTemplateHierarchyID;
    }

    public void setAttributeDatasetTemplateHierarchyID(DatasetTemplateHierarchy attributeDatasetTemplateHierarchyID) {
        this.attributeDatasetTemplateHierarchyID = attributeDatasetTemplateHierarchyID;
    }

    @XmlTransient
    public Collection<DiscreteAsset> getDiscreteAssetCollection() {
        return discreteAssetCollection;
    }

    public void setDiscreteAssetCollection(Collection<DiscreteAsset> discreteAssetCollection) {
        this.discreteAssetCollection = discreteAssetCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (assetCategoryID != null ? assetCategoryID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AssetCategory)) {
            return false;
        }
        AssetCategory other = (AssetCategory) object;
        if ((this.assetCategoryID == null && other.assetCategoryID != null) || (this.assetCategoryID != null && !this.assetCategoryID.equals(other.assetCategoryID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.openams.server.entity.AssetCategory[ assetCategoryID=" + assetCategoryID + " ]";
    }
    
}
